//变量
var a; //只是声明变量不知道变量的数据类型
var b=9.9;
var c='M';
var x=10;   //声明变量的时候，只有在赋值的时候知道类型
var y ;
y='Smith';
var z=false;
var d='20';
var e='9.9';
var f=e/10;


// console.log("a =" + a) //undefined
// console.log("x =" + x) //10
//数据类型: number string  boolean
console.log(typeof a) //undefined
console.log(typeof b)//number
console.log(typeof c)//string 
console.log(typeof x)//Number
console.log(typeof y)//string
console.log(typeof z)//boolean

//类型转换
var a1= parseInt(d)
var a2=parseFloat(e)
console.log("a1 =" + a1)
console.log( "typeof a1 =" + typeof(a1))
console.log("a1 =" + a2)
console.log(  "typeof a2 =" +typeof(a2))

//NaN : not a number 不是一个number类型的变量（是 非数值类型）

console.log(isNaN(e))//false
console.log(isNaN("hello"))//true
var a3="aaa";
var a4=44/a3;
console.log(isNaN(a4))//NaN

//if-else 与 Java一样
//for
for(var i=0;i<10;i++){
    console.log(i)
}
//java中的数组、集合-------JS数组
var  arr1=[10,20,30];
console.log(arr1)
for(var i=0;i<arr1.length;i++){
    console.log(arr1[i])
}
console.log("个数"+arr1.length)
console.log( "第二个元素是："+arr1[1])
//数组长度可变
arr1[3]=40
arr1[4]=50
console.log("个数"+arr1.length)

//对象
var student={
    stuId:101,
    stuName:"小张",
    stuGender:"M",
    stuAge:20
}
console.log(student)
console.log(student.stuName)

//创建3个car对象放在数组中，遍历输出
var car1={
    carId:1001,
    carName:"su7",
    carBrand:"xiaomi"
}
var car2={
    carId:1002,
    carName:"modelY",
    carBrand:"tesila"
}
var car3={
    carId:1003,
    carName:"X5",
    carBrand:"BMW"
}
var arr2=[car1,car2,car3]
//for循环遍历
for(var i=0;i<arr2.length;i++){
    console.log(arr2[i])
}
//foreach遍历
arr2.forEach(element => {
    console.log(element)
});
//消息确认框
//所有的删除都要有消息确认框
if(window.confirm("你确定要删除这条记录吗？")){
    //调用后端删除记录
}
//链接到某个url(windows可以省略)======等价于<a href="a.html"></a>
// window.location.href='a.html'

//函数 function
function fun1(p1,p2){
    var p3=p1+p2
    console.log( "p3 = "+p3)
}
fun1(10,20)
// var result= fun1(10,20)
